﻿using SmartCMS.UI.Helper;
using SmartCMS.UI.ViewModels;
using SmartControls.Controls;
using SmartControls.OutlookGrid;
using SmartControls.Toolkit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WinFormsUI.Docking;

namespace SmartCMS.UI
{
    public partial class UserListForm : DockContent
    {
        public UserListForm()
        {
            InitializeComponent();
        }

        private void UserListForm_Load(object sender, EventArgs e)
        {
            kryptonOutlookGrid1.GroupBox = kryptonOutlookGridGroupBox1;
            kryptonOutlookGrid1.RegisterGroupBoxEvents();
            OutlookGridRow row = new OutlookGridRow();
            kryptonOutlookGrid1.SuspendLayout();
            kryptonOutlookGrid1.ClearInternalRows();
            List<OutlookGridRow> listOG = new List<OutlookGridRow>();
            var Users = DBHelper.GetCollection<ViewModels.UserInfo>().FindAll();
            IFormatProvider culture = new CultureInfo("cn-ZH", true);
            //DataGridViewColumn[] columnsToAdd = new DataGridViewColumn[3];
            //DataGridViewColumn  column = new KryptonDataGridViewTextBoxColumn();
            //column.SortMode = DataGridViewColumnSortMode.Programmatic;
            //columnsToAdd[0] = column;
            //kryptonOutlookGrid1.AddInternalColumn(columnsToAdd[0], new OutlookGridDefaultGroup(null), SortOrder.None, -1, -1);
            //kryptonOutlookGrid1.Columns.AddRange(columnsToAdd);
            foreach (var item in Users)
            {
                row = new OutlookGridRow();
                row.CreateCells(kryptonOutlookGrid1, new object[] {
                    item.Id,
                    item.UserName,
                    item.Sex
                 });
                listOG.Add(row);
            }
            kryptonOutlookGrid1.ResumeLayout();
            kryptonOutlookGrid1.AssignRows(listOG);
            kryptonOutlookGrid1.ForceRefreshGroupBox();
            kryptonOutlookGrid1.Fill();
        }

        private void kryptonOutlookGrid1_Resize(object sender, EventArgs e)
        {

        }
    }
}
